﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using Vra.DataAccess.Entities;
using System.Windows.Forms;

namespace Vra.DataAccess
{
    public class CAIntDao : BaseDao, ICAIntDao
    {

        private static CAint LoadCaints(SqlDataReader reader)
        {

            CAint @CAint = new CAint();

            @CAint.ArtistId = reader.GetInt32(reader.GetOrdinal("ArtistID"));

            @CAint.CustomerId = reader.GetInt32(reader.GetOrdinal("CustomerID"));

            return @CAint;
        }


        public IList<CAint> GetAll()
        {
            IList<CAint> Caints = new List<CAint>();
            using (var conn = GetConnection())
            {
                conn.Open();
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "SELECT * FROM CUSTOMER_ARTIST_INT";
                    using (var dataReader = cmd.ExecuteReader())
                    {
                        while (dataReader.Read())
                        {
                            Caints.Add(LoadCaints(dataReader));
                        }
                    }
                }
            }

            return Caints;

        }
    }
}
